04.Running commands
NOTE For this lab, you need PowerShell v7 or later running on Windows, macOS, or Linux.
Using what you learned in this chapter, and in the previous chapter on using the help system, complete the following tasks in PowerShell:
- Display a list of running processes.
- Test the connection to google.com or bing.com without using an external command like
ping
. - Display a list of all commands that are of the cmdlet type. (This is tricky—we’ve shown you
Get-Command
but you need to read the help to find out how to narrow down the list as we’ve asked.) - Display a list of all aliases.
- Make a new alias, so you can run
ntst
to runnetstat
from a PowerShell prompt. - Display a list of processes that begin with the letter p. Again, read the help for the necessary command—and don’t forget that the asterisk (
*
) is a near-universal wildcard in PowerShell. - Make a new folder (aka directory) using the
New-Item
cmdlet with the name of MyFolder1. Then do it again and call it MyFolder2. UseHelp
if you’re not familiar withNew-Item
. - Remove the folders from step 7 in a single command. Use
Get-Command
to find a similar cmdlet to what we used in step 7—and don’t forget that the asterisk (*
) is a near-universal wildcard in PowerShell.
We hope these tasks seem straightforward to you. If so—excellent. You’re taking advantage of your existing command-line skills to make PowerShell perform a few practical tasks for you. If you’re new to the command-line world, these tasks are a good introduction to what you’ll be doing in the rest of this book.